{layout name="public/layout" /}
		{include file='yxnavbar'}
<link rel="stylesheet" href="{$_G['URL']['APP_CSS']}back.css">
<style type="text/css">
	.order-detail-info>div{margin-bottom:10px; padding-left:15px;}
	.page-trade-order h4{font-size:14px; font-weight:700;}
	.page-trade-order .form-group{margin-bottom:0;}
	.page-trade-order .form-group .control-label{font-weight:normal; color:#999;}
	.page-trade-order .order-infos{border-right:1px solid #ddd;}
	.page-trade-order .parting-line{height:1px;border-top:1px dashed #e5e5e5; margin:3px 0;}
	.page-trade-order .order-state{padding-left:40px; position:relative; margin:20px 0 40px;}
	.page-trade-order .order-state>span{color:#07d; position:absolute; left:0; top:5px; font-size:25px; display:inline-block; width:30px; height:30px; border:1px solid #07d; border-radius:30px; text-align:center; line-height:30px;}
	#close-order ul li{padding:5px 15px; cursor:pointer;}
	#close-order ul li:hover{background:#eee;}
	.fix a.js-order-edit-address{display:none; color:red;}
	.fix:hover a.js-order-edit-address{display:inline;}
	.page-trade-order .col-sm-9{word-break: break-word; overflow:hidden;}
	.table-log>tbody>tr>td{border-top:none;}
</style>
{if $op == 'post'}
<div class="clearfix">
	<form class="form-horizontal form" id="form1" action="" method="post" enctype="multipart/form-data">
		<div class="panel panel-default">
			<div class="panel-heading">卡密信息</div>
			<div class="panel-body">
				<div class="form-group">
					<label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"><span class="require">* </span>卡号</label>
					<div class="col-sm-8 col-xs-12">
						<input type="text" class="form-control" name="code" value="{$item['code']}">
						<div class="help-block">必填</div>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"><span class="require">* </span>密码</label>
					<div class="col-sm-8 col-xs-12">
						<input type="text" class="form-control" name="pwd" value="{$item['pwd']}">
						<div class="help-block">选填</div>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"><span class="require">* </span>进行时</label>
					<div class="col-sm-8 col-xs-12">
						<input type="text" class="form-control" name="ing" value="{$item['ing']}">
						<div class="help-block">选填 活动进行时显示的信息</div>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"><span class="require">* </span>结束后</label>
					<div class="col-sm-8 col-xs-12">
						<input type="text" class="form-control" name="end" value="{$item['end']}">
						<div class="help-block">选填 活动结束后显示的信息</div>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"><span class="require">* </span>提示信息</label>
					<div class="col-sm-8 col-xs-12">
						<input type="text" class="form-control" name="tips" value="{$item['tips']}">
						<div class="help-block">选填 提示粉丝的信息</div>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require">*</span>活动记录ID</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="openid" readonly value="{$item['recordid']}" class="form-control">
						<div class="help-block">团长或者团员的ID</div>
					</div>
				</div>
				<div class="form-group" id="username">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require">*</span>Openid</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="openid" readonly value="{$item['openid']}" class="form-control">
						<div class="help-block"></div>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require">*</span>UID</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="uid" readonly value="{$item['uid']}" class="form-control">
						<div class="help-block"></div>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"><span class="require">* </span>昵称</label>
					<div class="col-sm-8 col-xs-12">
						<input type="text" class="form-control" readonly name="nickname" value="{$item['nickname']}">
						<div class="help-block"></div>
					</div>
				</div>

				<div class="form-group">
                     <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"><span class="text-danger">*</span>状态</label>
                    	<div class="col-sm-9 col-md-8 col-lg-8 col-xs-12">
							<label class="radio-inline">
								<input name="status" value="0" {if $item['status']==0} checked="checked"{/if} type="radio"> 暂停
							</label>
							<label class="radio-inline">
								<input name="status" value="1" {if $item['status']==1} checked="checked"{/if} type="radio"> 启用
							</label>
							<label class="radio-inline">
								<input name="status" value="2" {if $item['status']==2} checked="checked"{/if} type="radio"> 核销
							</label>
						</div>
                </div> 
			</div>
		</div>
		<div class="form-group col-sm-12">
			<input name="submit" id="submit" type="submit" value="提交" class="btn btn-primary col-lg-1">
			<input type="hidden" name="__token__" value="{$Request.token}" />
		</div>
	</form>
</div>
<script type="text/javascript">

</script>
{else}
<div class="mian">
	<div class="panel panel-info">
		<div class="panel-heading">当前数量： {$total}</div>
		<div class="panel panel-default">
		<div class="panel-body">
			<form id="addform" action="./index.php" method="post" class="form-horizontal" enctype="multipart/form-data">
				<input type="hidden" name="c" value="site" />
				<input type="hidden" name="a" value="entry" />
				<input type="hidden" name="m" value="{$_P['m']}" />
				<input type="hidden" name="do" value="{$do}" />
				<input type="hidden" name="themeid" value="{$themeid}" />
				<input type="hidden" name="op" value="import" />
			    <div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-1 control-label">Excel文件</label>
					<div class="col-sm-3 col-lg-3 col-md-3 col-xs-6">
                        <input type="file" class="form-control"  name="file">
                    </div>
					<div class="col-xs-12 col-sm-4 col-md-4 col-lg-4">
						<input type="submit" class="btn btn-primary" value="导入">
					</div>
                </div>

			</form> 

			<form action="./index.php" method="get" class="form-horizontal" role="form">
				<input type="hidden" name="c" value="site" />
				<input type="hidden" name="a" value="entry" />
				<input type="hidden" name="m" value="{$_P['m']}" />
				<input type="hidden" name="do" value="{$do}" />
				<input type="hidden" name="themeid" value="{$themeid}" />
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-1 control-label">用户信息</label>
					<div class="col-sm-3 col-lg-3 col-md-3 col-xs-6">
						<input class="form-control" name="keyword" placeholder="输入用户名或手机号" type="text" value="{$_P['keyword']}">
					</div>
					<div class="col-xs-12 col-sm-4 col-md-4 col-lg-4">
						<button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
						<input type="hidden" name="__token__" value="{$Request.token}"/>
					</div>
				</div>
			</form>
		</div>
	</div>
	</div>

		<ul class="order-nav order-nav-tabs">
			<li {if $status == -1}class="active"{/if}><a href="{php echo filter_url('status:-1');}">所有记录</a></li>
			<li {if $status == 0}class="active"{/if}><a href="{php echo filter_url('status:0');}">暂停</a></li>
			<li {if $status == 1}class="active"{/if}><a href="{php echo filter_url('status:1');}">启用</a></li>
			<li {if $status == 2}class="active"{/if}><a href="{php echo filter_url('status:2');}">核销</a></li>
		</ul>
		<div class="panel panel-default">
			<div class="panel-body table-responsive">
				<table class="table table-hover">
					<thead class="navbar-inner">
						<tr>
							<th>ID</th>
							<th>卡号</th>
							<th>密码</th>
							<th>提示</th>
							<th>进行</th>
							<th>结束</th>
							<th>记录ID</th>
							<th>昵称</th>
							<th>头像</th>
							<th>状态</th>
							<th style="width:150px; text-align:right;">操作</th>
						</tr>
					</thead>
					<tbody>
						{loop $list $row}
						<tr>
						    <td>{$row['id']}</td>
							<td><b>{$row['code']}</b></td>
							<td><b>{$row['pwd']}</b></td>
							<td>{$row['tips']}</td>
							<td>{$row['ing']}</td>
							<td>{$row['end']}</td>
							<td>{$row['recordid']}</td>
							<td style="font-size: 10px;">{$row['nickname']}</td>
							<td><img src="{php echo tomedia($row['avatar']);}" width="28" style="bsection-radius: 3px;"></td>
							<td>
								{if $row['status']==0}暂停{elseif $row['status']==1}启用{else}核销{/if}
							</td>
							<td style="text-align:right;">
							<a class="btn btn-success btn-sm"
							href="{php echo createWebUrl($do, array('op'=>'post','id'=>$row['id'],'themeid'=>$themeid));}"
							title="编辑设置"><i class="fa fa-edit"> </i></a>
								<a href="{php echo createWebUrl($do, array('op' => 'delete', 'themeid'=>$themeid,'id' => $row['id']));}" class="btn btn-warning btn-sm" title="删除" data-toggle="tooltip" data-placement="top" onclick="if(!confirm('删除后将不可恢复，确定删除吗?')) return false;"><i class="fa fa-times"> </i></a>
							</td>
						</tr>
						{/loop}
					</tbody>
				</table>
			</div>
		</div>
		{$pager}
</div>

<script type="text/javascript">
	$(function(){
		$('.app-preview').click(function(){
			return false;
		});
		require(['underscore', 'bootstrap.switch'], function() {
			$(":checkbox[name='status[]']").bootstrapSwitch();
			$(':checkbox').on('switchChange.bootstrapSwitch', function(e, state){
				$this = $(this);
				var id = $(this).data('id');
				var status = this.checked ? 1 : 0;
				$.post("{php echo createWebUrl('fake', array('op' => 'status','themeid'=>$themeid));}", {status:status,id: id}, function(resp){
					resp = $.parseJSON(resp);
					if(resp.message.errno != 0) {
						layer.msg('操作失败, 请稍后重试');
					} else {
						layer.msg('操作成功');
					}
				});
			});
		});
	});
</script>
{/if}
